package com.llg.controller;

import com.llg.model.response.DataResult;
import com.llg.model.response.PageResult;
import com.llg.model.response.ResponseResult;
import com.llg.pojo.SupplySpec;
import com.llg.service.SupplySpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/supplySpec")
public class SupplySpecController {
    @Autowired
    private SupplySpecService supplySpecService;

    //通过品牌id查找所有型号
    @GetMapping("/findByBrandId")
    public PageResult<SupplySpec> findByBrandId(Integer bid){
        return supplySpecService.findByBrandId(bid);
    }

    //搜索并分页查询
    @PostMapping("/findList")
    public PageResult<SupplySpec> findList(Integer currentPage,Integer pageSize,@RequestBody SupplySpec supplySpec){
        return supplySpecService.findList(currentPage, pageSize, supplySpec);
    }

    //通过id查
    @GetMapping("/{id}")
    public DataResult<SupplySpec> findById(@PathVariable("id") Integer id){
        return supplySpecService.findById(id);
    }

    //增
    @PostMapping("/add")
    public DataResult<SupplySpec> add(@RequestBody SupplySpec supplySpec){
        return supplySpecService.add(supplySpec);
    }

    //删
    @GetMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return supplySpecService.delete(id);
    }
    
    //改
    @PostMapping("/update")
    public ResponseResult update(@RequestBody SupplySpec supplySpec){
        return supplySpecService.update(supplySpec);
    }
}
